<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <title>申请理赔</title>
    <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no'
          name='viewport'/>
    <link rel="stylesheet" href="assets/css/bootstrap.min.css">
    <link rel="stylesheet"
          href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i">
    <link rel="stylesheet" href="assets/css/ready.css">
    <link rel="stylesheet" href="assets/css/demo.css">
    <script src="../homePage/bootstrap/js/jquery.min.js"></script>
    <script src="../homePage/layer/layer.js"></script>
    <script src="bootstrap/js/bootstrap.js"></script>
    <script src="angularjs/angular.min.js"></script>
</head>
<style type="text/css">
    .main-panel {
        background-color: #FFFFFF !important;
    }

    .content {
        background-color: #FFFFFF !important;
    }
</style>
<script>
    /*   //初始化数据
       function getDigital() {
           var myuser = sessionStorage.getItem("user");
           var userid = JSON.parse(myuser).userid

           /!*
                       var u = "";
                       u+="<span id='existname'>"+JSON.parse(myuser).username+"</span>"
                       u+="<span id='existtel'>"+JSON.parse(myuser).usertel+"</span>"
                       $("#thename").html(u)
                       if (JSON.parse(myuser).username == null ||JSON.parse(myuser).username=="" ){
                           $("#existname").hide()
                       }
                       if (JSON.parse(myuser).usertel!= null){
                           $("#existtel").hide()
                       }*!/
           $.ajax({
               async: false,
               url: "http://localhost:8002/tuser/showinfo/" + userid,
               type: "GET",
               success: function (data) {
                   var user = data.data;
                   //查看是否绑定银行卡
                   $.ajax({
                       async: false,
                       url: "http://localhost:8002/bank/selectAllBank/" + userid,
                       type: "GET",
                       success: function (data) {
                           var bank = data.data;
                           if (user.username != "") {
                               $("#username").hide()
                           }
                           if (user.usertel != "") {
                               $("#usertel").hide()
                           }
                           if (user.password != "") {
                               $("#password").hide()
                           }
                           if (user.idnumber != "") {
                               $("#idnumber").hide()
                           }
                           if (user.email != "") {
                               $("#email").hide()
                           }
                           ;
                           if (user.username == "") {
                               $("#username1").hide()
                           } else {
                               var username = "";
                               username += "<p>" + user.username + "</p>";
                               $("#pusername").html(username)
                           }
                           if (user.usertel == null) {
                               $("#usertel1").hide()
                           } else {
                               var usertel = "";
                               usertel += "<p>" + user.usertel + "</p>";
                               $("#pusertel").html(usertel)
                           }
                           if (user.idnumber == "") {
                               $("#idnumber1").hide()
                           }
                           if (user.email == "") {
                               $("#email1").hide()
                           }
                           if (bank != null) {
                               $("#bankcard").hide()
                               var c = "";
                               $(bank).each(function (i, v) {
                                   c += "<p>" + v.bankcard + "</p>";
                               })
                               $("#tb").html(c)
                           } else {
                               $("#bankcard1").hide()
                           }

                       }
                   })


               }
           });
       }*/
    var app = angular.module("myApp",[]);
    app.controller("myCtrl",function ($scope,$http) {
        var item = sessionStorage.getItem("user");
        $scope.username = JSON.parse(item).username;
    })

</script>
<body>
<div class="wrapper">
    <div class="main-header">
        <div class="logo-header">
            <a href="index.html" class="logo">
                <img src="../homePage/img/logo.png" style="height: 40px;width: 100px">个人中心
            </a>
            <button class="navbar-toggler sidenav-toggler ml-auto" type="button" data-toggle="collapse"
                    data-target="collapse"
                    aria-controls="sidebar" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <button class="topbar-toggler more"><i class="la la-ellipsis-v"></i></button>
        </div>
        <nav class="navbar navbar-header navbar-expand-lg">
            <div class="container-fluid">
                <a href="../homePage/index.html" style="color: #000000; font-size: 16px;">返回首页</a>

                <ul class="navbar-nav topbar-nav ml-md-auto align-items-center">


                    <li class="nav-item dropdown">当前用户:
                        <a class="dropdown-toggle profile-pic" data-toggle="dropdown" href="#" aria-expanded="false">
                            <span ng-app="myApp" ng-controller="myCtrl">{{username}}</span>
                        </a>
                        <ul class="dropdown-menu dropdown-user">
                            <li>
                                <div class="user-box">

                                    <div class="u-text">
                                        <a onclick="quiet()" class="btn btn-rounded btn-danger btn-sm">退出登录</a>
                                    </div>
                                </div>
                            </li>

                        </ul>
                        <!-- /.dropdown-user -->
                    </li>
                </ul>
            </div>
        </nav>
    </div>
    <div class="sidebar">
        <div class="scrollbar-inner sidebar-wrapper">
            <div class="user">
                <div class="info">
                    <a class="" data-toggle="collapse" href="#collapseExample" aria-expanded="true">
								<span>
									<span class="user-level">修改信息</span>
                                    <!-- <span class="badge badge-count">未实名</span> -->
									<span class="caret"></span>
								</span>
                    </a>
                    <div class="clearfix"></div>

                    <div class="collapse in" id="collapseExample" aria-expanded="true" style="">
                        <ul class="nav">
                            <li>
                                <a href="password.html">
                                    <span class="link-collapse">修改密码</span>
                                </a>
                            </li>
                            <li>
                                <a href="authentication.html">
                                    <span class="link-collapse">实名认证</span>
                                </a>
                            </li>
                            <li>
                                <a href="update.html">
                                    <span class="link-collapse">编辑资料</span>
                                </a>
                            </li>
                            <li>
                                <a href="gobindcar.html">
                                    <span class="link-collapse">绑定车辆</span>
                                </a>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
            <ul class="nav">
                <li class="nav-item">
                    <a href="home.html">
                        <i class="la la-fonticons"></i>
                        <p>首页管理</p>
                        <!-- <span class="badge badge-count">5</span> -->
                    </a>
                </li>
                <li class="nav-item">
                    <a href="myOrder.html">
                        <i class="la la-dashboard"></i>
                        <p>我的订单</p>
                        <!-- <span class="badge badge-count">5</span> -->
                    </a>
                </li>
                <li class="nav-item">
                    <a href="guarantee.html">
                        <i class="la la-table"></i>
                        <p>我的保单</p>
                        <!-- <span class="badge badge-count">14</span> -->
                    </a>
                </li>
                <li class="nav-item">
                    <a href="claim.html">
                        <i class="la la-keyboard-o"></i>
                        <p>我的理赔</p>
                        <!-- <span class="badge badge-count">50</span> -->
                    </a>
                </li>
                <li class="nav-item">
                    <a href="bindcar.html">
                        <i class="la la-th"></i>
                        <p>我的车辆</p>
                        <!-- <span class="badge badge-count">6</span> -->
                    </a>
                </li>
                <li class="nav-item active">
                    <a href="applyclaim.html">
                        <i class="la la-th"></i>
                        <p>申请理赔</p>
                        <!-- <span class="badge badge-count">6</span> -->
                    </a>
                </li>
            </ul>
        </div>
    </div>
    <div class="main-panel">
        <div class="content">
            <div class="container-fluid">
                <h4 class="page-title">理赔申请</h4>
                <div class="row">
                    <div class="col-md-10">
                        <div class="card">
                            <div class="card-header bg-light">
                                <h4 class="card-title">信息上传</h4>
                                <div class="card-category">请完善以下信息</div>
                            </div>
                            <div class="card-body">
                                <p><span style="color: red">1.请上传现场清晰照片</span></p>
                                <form action="" method="post" enctype="multipart/form-data">
                                    <input class="btn btn-default" type="file" id="img" name="img"
                                           accept="image/png,image/jpeg,image/jpg"/>

                                    <button type="button" onclick="upload()" class="btn btn-default"> 提 交</button>
                                </form>
                                <p class="card-category">图片格式支持jpg、png、bmp，图片的长和宽要求最短边大于10px，最长边小于2048 px;</p>
                                <p class="card-category">图片大小必须小于4M，建议不要超过1M；</p>
                                <p class="card-category">请尽量将图片高和宽都控制在1000 px以下，图片尽量没有反光、倾斜小于10度;</p>

                                <div id="cardDemo">
                                    <input id="imgPath" type="hidden"/>
                                </div>
                                <div class="form-inline"><span style="color: red">2.请输入出险时间:</span><input
                                        class="form-control" id="risktime"
                                        name="risktime" placeholder="出险时间"
                                        type="date"></div>

                                <br>
                                <div class="form-inline"><span style="color: red">3.请输入报案时间:</span><input
                                        class="form-control" id="reporttime"
                                        name="reporttime" placeholder="报案时间"
                                        type="date"></div>

                                <br>
                                <div class="form-inline"><span style="color: red">4.请输入保单号&nbsp:&nbsp&nbsp</span><input
                                        class="form-control" id="policynum"
                                        name="policynum" placeholder="保单号"/>&nbsp;&nbsp;
                                    <span id="bdh" style="color: red"></span>
                                </div>
                                <br/>
                                <div class="form-inline"><span style="color: red">5.&nbsp联&nbsp系&nbsp电&nbsp话&nbsp &nbsp:&nbsp &nbsp</span><input
                                        class="form-control" id="reportertel"
                                        name="reporterTel" placeholder="联系电话">
                                </div>

                            </div>
                            <div class="card-footer text-center">
                                <a class="btn btn-info" onclick="apply()">提交申请</a>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </div>
        <footer class="footer">
            <div class="container-fluid">
                <nav class="pull-left">
                    <ul class="nav">
                        <li class="nav-item">
                            <a class="nav-link" href="#">
                                ThemeKita
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#">
                                Help
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#license/#free-item">
                                Licenses
                            </a>
                        </li>
                    </ul>
                </nav>
                <div class="copyright ml-auto">
                    Copyright &copy; 2020 无忧车险责任有限公司
                </div>
            </div>
        </footer>
    </div>
</div>
</body>
<script src="assets/js/core/jquery.3.2.1.min.js"></script>
<script src="assets/js/plugin/jquery-ui-1.12.1.custom/jquery-ui.min.js"></script>
<script src="assets/js/core/popper.min.js"></script>
<script src="assets/js/core/bootstrap.min.js"></script>
<script src="assets/js/plugin/chartist/chartist.min.js"></script>
<script src="assets/js/plugin/chartist/plugin/chartist-plugin-tooltip.min.js"></script>
<script src="assets/js/plugin/bootstrap-notify/bootstrap-notify.min.js"></script>
<script src="assets/js/plugin/bootstrap-toggle/bootstrap-toggle.min.js"></script>
<script src="assets/js/plugin/jquery-mapael/jquery.mapael.min.js"></script>
<script src="assets/js/plugin/jquery-mapael/maps/world_countries.min.js"></script>
<script src="assets/js/plugin/chart-circle/circles.min.js"></script>
<script src="assets/js/plugin/jquery-scrollbar/jquery.scrollbar.min.js"></script>
<script src="assets/js/ready.min.js"></script>
<!--<script src="assets/js/demo.js"></script>-->

<script>

    function upload() {
        index = layer.load(1);
        var img = new FormData();
        img.append("img", $("#img").get(0).files[0]);
        $.ajax({
            url: "http://localhost:8002/policy/upload",
            type: "POST",
            data: img,
            processData: false,
            contentType: false,
            success: function (data) {
                layer.close(index);
                layer.msg(data.msg);
                if (data.code === 1) {
                    // alert(data.data);
                    $("#imgPath").val(data.data);
                    //$("#imgPath").attr("src", "../uploadFile/" + data.data);
                    // $('#save').removeAttr("disabled"); //移除disabled属性
                }
            },
            error: function () {
                layer.close(index);
                alert("请选择清晰的图片上传");
            }
        });
    }

    let user = sessionStorage.getItem("user");
    var userid = JSON.parse(user).userid;
    var username = JSON.parse(sessionStorage.getItem("user")).username;
    $("#username").html(username);
    // var userid = 40;
    function apply() {
        //判断图片上传没有
        if ($("#imgPath").val() === '') {
            layer.msg("请先提交图片！");
        } else {
            //判断输入框的值是否为空
            if ($("#reporttime").val() === '' && $("#reporttime").val() === '' && $("#policynum").val() === ''
                && $("#reportertel").val() === '') {
                layer.msg("请将申请信息填写完善！");
            } else {
                $.ajax({
                    url: "http://localhost:8002/policy/claim?imgPath=" + $("#imgPath").val() + "&risktime=" + $("#reporttime").val() +
                    "&reporttime=" + $("#reporttime").val() + "&policynum=" + $("#policynum").val() + "&userid=" + userid
                    + "&reporterTel=" + $("#reportertel").val(),
                    type: "GET",
                    success: function (data) {
                        layer.msg(data.msg)
                    },
                    error: function () {
                        layer.msg("申请失败，请重新申请！");
                    }
                });
            }

        }
    }

    function quiet() {
        sessionStorage.clear()
        window.location.href = "../homePage/index.html";
    }

    $("#policynum").on({
        mouseout: function () {
            $.ajax({
                    url: "http://localhost:8002/policy/selectPolicyno?policyno=" + $("#policynum").val() + "&userid=" + userid,
                    type: "GET",
                    success: function (data) {
                        if (data.code==0) {
                            $("#bdh").html(data.msg);
                        }else if (data.code == 101) {
                            $("#bdh").html(data.msg);
                        }
                    },
                    error: function () {
                        $("#bdh").html("没有该保单号");
                    }
                }
            )
        }
    })

</script>
</html>
